package com.czy.owner.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.entity.BulletinModel;
import com.czy.owner.utils.TimeUtils;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by hedepu on 2017/09/30 0018.
 */

public class BulletinListAdapter extends RecyclerArrayAdapter<BulletinModel.ListBean> {

    private Context context;


    public BulletinListAdapter(Context context) {
        super(context);
        this.context = context;
    }


    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new BulletinListViewHolder(parent);
    }

    class BulletinListViewHolder extends BaseViewHolder<BulletinModel.ListBean> {


        @BindView(R.id.tv_item_find_title)
        TextView tvItemFindTitle;
        @BindView(R.id.img_hot)
        ImageView imgHot;
        @BindView(R.id.tv_time)
        TextView tvTime;

        public BulletinListViewHolder(ViewGroup parent) {
            super(parent, R.layout.item_bulletin_recyler);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(final BulletinModel.ListBean data) {
            super.setData(data);
            tvItemFindTitle.setText(data.getTitle());
            tvTime.setText("发布时间：" + TimeUtils.timeStamp2Date(data.getCreateTime() + "", "yyyy-MM-dd HH:mm"));
            if (data.isTop()) {
                imgHot.setVisibility(View.VISIBLE);
            } else {
                imgHot.setVisibility(View.GONE);
            }
        }
    }

}